package com.kayak.emailWorks.quartz.travelDays;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.kayak.dbutil.dao.ComnDao;
import com.kayak.dbutil.sql.SqlRow;
import com.kayak.emailWorks.util.EmailTempletMarket;
import com.kayak.emailWorks.util.SendEmailHtml;
import com.kayak.exception.ErrorException;
import com.kayak.kkweb.sys.SysBeans;

/**
 *
 * 填写出差天数通知邮件处理类
 *
 */
public class FillTravelDaysNotice {

	public static void doIt() throws IOException {
		String username = EmailTempletMarket.FETCHEMAILADDRESS;
		String password = EmailTempletMarket.FETCHMAILPASSAGES;
		ComnDao comnDao = SysBeans.getComnDao();
		List<SqlRow> sendList = new ArrayList<SqlRow>();
		try {
			sendList = comnDao.query("Eselectuserinfo", new HashMap<String, Object>()).getRows();
		} catch (ErrorException e) {
			e.printStackTrace();
		}
		for (Map<String, Object> temp : sendList) {
			String name = temp.get("name").toString();
			String content = EmailTempletMarket.SendMailTemplet(name);
			String toUser = temp.get("email").toString();
			String title = EmailTempletMarket.SendMailTitle;
			new SendEmailHtml().sendAEmail(username, password, title, content, toUser);
		}
	}
	
}
